package org.domain.sigerec.session;

import java.util.Arrays;
import java.util.List;

import org.domain.sigerec.entity.Reserva;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;

@Name("reservaList")
public class ReservaList extends EntityQuery<Reserva>
{
    /**
	 * 
	 */
	private static final long serialVersionUID = 1356063212669356624L;
	
	private static final String[] RESTRICTIONS = { "lower(cliente.nome) like concat(lower(#{clienteList.cliente.nome}),'%')", };
	
	private Reserva reserva = new Reserva();

	@Override
    public String getEjbql() 
    { 
        return "select reserva from Reserva reserva";
    }
	
	public Reserva getReserva() {
		return reserva;
	}
	
	@Override
	public List<String> getRestrictions() {
		return Arrays.asList(RESTRICTIONS);
	}

	private boolean pesquisou;

	public List<Reserva> getReservas() {
		if (pesquisou || getFirstResult()!=null) {
			return getResultList();
		}
		return null;
	}

	public String pesquisar() {
		pesquisou = true;
		return null;
	}
	
}
